package com.liujie.dhunting.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.liujie.dhunting.entity.Resume;
import com.liujie.dhunting.mapper.CustomerMapper;
import com.liujie.dhunting.mapper.ResumeMapper;
import com.liujie.dhunting.utils.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/home")
public class HomeController {

    @Resource
    ResumeMapper resumeMapper;
    CustomerMapper customerMapper;



    @GetMapping("/load")
    public Result<?> load(@RequestParam Date t1,@RequestParam Date t2){
        List<Long> countList=new ArrayList<>();
        countList.add(resumeMapper.selectCount(Wrappers.<Resume>lambdaQuery()
                .between(Resume::getTime,t1,t2).eq(Resume::getRstate,"新增")));
        countList.add(resumeMapper.selectCount(Wrappers.<Resume>lambdaQuery()
                .between(Resume::getTime,t1,t2).eq(Resume::getRstate,"初筛")));
        countList.add(resumeMapper.selectCount(Wrappers.<Resume>lambdaQuery()
                .between(Resume::getTime,t1,t2).eq(Resume::getRstate,"推荐")));
        countList.add(resumeMapper.selectCount(Wrappers.<Resume>lambdaQuery()
                .between(Resume::getTime,t1,t2).eq(Resume::getRstate,"初试")));
        countList.add(resumeMapper.selectCount(Wrappers.<Resume>lambdaQuery()
                .between(Resume::getTime,t1,t2).eq(Resume::getRstate,"复试")));
        countList.add(resumeMapper.selectCount(Wrappers.<Resume>lambdaQuery()
                .between(Resume::getTime,t1,t2).eq(Resume::getRstate,"终试")));
        countList.add(resumeMapper.selectCount(Wrappers.<Resume>lambdaQuery()
                .between(Resume::getTime,t1,t2).eq(Resume::getRstate,"offer")));
        countList.add(resumeMapper.selectCount(Wrappers.<Resume>lambdaQuery()
                .between(Resume::getTime,t1,t2).eq(Resume::getRstate,"入职")));
        countList.add(resumeMapper.selectCount(Wrappers.<Resume>lambdaQuery()
                .between(Resume::getTime,t1,t2).eq(Resume::getRstate,"过保")));
        return Result.success(countList);
    }
}
